Move the token_remover cog tests to unittest.#526
Conversation
Move the `sync` cog tests to `unittest`.
I've added a `self.subTest` to the `name` loop so we still test and get output for all names in the list if one of them fails the test. In addition, I've moved it to the `tests/bot/resources` subdirectory.
| self.bot.get_cog.return_value.send_log_message = AsyncMock() | ||
| self.cog = TokenRemover(bot=self.bot) | ||
|
|
||
| self.msg = MagicMock() |
There was a problem hiding this comment.
Probably a good idea to create a mock helper for messages and use mocks with specs for some of the attributes here (like the author and channel).
There was a problem hiding this comment.
That seems reasonable to me.
I think we should factor out the mocking of those Discord "Model" that we use a lot and typically require the same or a very similar set-up. Since it does mean we'd basically have to maintain and test a small discord.py mocking library, I'd say we should restrict it those those base models though. I think that with a set of Member, Guild, Role, Message, TextChannel, Context, Bot, and Role we've covered a lot of things that we typically usr.
There was a problem hiding this comment.
@MarkKoz @jchristgit I'm going to add a couple more specific mocks and tests, but I'll resolve this during the merge.
There was a problem hiding this comment.
So this means this should be left alone for now?
Migrates the `test_constants.py` file to unittest. As with the pytest version, there is not yet support to test container types.
Migrate `test_constants` to unittest
This commit introduces some new Mock-types to the already existing Mock-types for discord.py objects. The total list is now: - MockGuild - MockRole - MockMember - MockBot - MockContext - MockTextChannel - MockMessage In addition, I've added all coroutines in the documentation for these discord.py objects as `AsyncMock` attributes to ease testing. Tests ensure that the attributes set for the Mocks exist for the actual discord.py objects as well.
…to unittest-migration
This commit replaces the standard MagicMocks by our specialized mocks for discord.py objects. It also adds the missing `channel` attribute to the `tests.helpers.MockMessage` mock and moves the file to the correct folder.
…d/bot into cogs-tokenremover-unittest
|
Uhm, I messed up the git history... But, I've merged this correctly on the command line, so I'm just going to close this. Sorry for that. (Please don't hurt me.) |
No description provided.